package com.dongdong.result;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)//开启链式编程，返回值是自身
public class Result<T> {
    private String  code;
    private String  msg;
    private T  data;

    public Result(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    //提供返回成功的方法
    public static Result OK(){return new Result(ResultEnums.SUCCESS.getCode(), ResultEnums.SUCCESS.getMsg());}
    //提供返回失败的方法
    public static Result ERROR(){return new Result(ResultEnums.ERROR.getCode(), ResultEnums.ERROR.getMsg());}
    //提供通用的方法
    public static Result RESPONSE(ResultEnums enums){return new Result(enums.getCode(), enums.getMsg());}










}
